<?php if (!defined('THINK_PATH')) exit();?><div class="bjui-pageHeader">
    <div class="pull-right">
        <button class="btn-default" data-icon="plus" title="新增分类" data-toggle="tooltip" data-placement="left" onclick="createDialog('<?php echo U("Forms/groy");?>', '新增分类', 'groy', {width:600, height:450})"></button>
        <button class="btn-default" data-icon="refresh" onclick="$.CurrentNavtab.navtab('refresh')"></button>
    </div>
    <form id="pagerForm" data-toggle="ajaxsearch" data-loadingmask="true" action="<?php echo U('Index/save');?>" method="post">
        <input type="hidden" name="pageSize" value="<?php echo I('param.pageSize');?>" />
        <input type="hidden" name="pageCurrent" value="<?php echo I('param.pageCurrent');?>" />
        <input type="hidden" name="orderField" value="<?php echo I('param.orderField');?>" />
        <input type="hidden" name="orderDirection" value="<?php echo I('param.orderDirection');?>" />
    </form>
</div>
<div class="bjui-pageContent tableContent">
    <table class="table table-bordered table-hover table-striped table-top groyTable" data-selected-multi="false">
        <thead>
            <tr>
                <th width="50">分类ID</th>
                <th>分类名称</th>
               <!--  <th width="140">手机显示名称</th> -->
                <th width="60">是否首页显示</th>
                <th width="60">状态</th>
                <th width="36">权重</th>
                <th width="100">操作</th>
            </tr>
        </thead>
        <tbody>
        <!--
            tr  class == groy1 是一级分类. groy2二级 开关事件,注意span.groys  和子元素的data-icon   plus && minus
        -->
       <?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr class="groy<?php echo ($vo["leve"]); ?>">
            <td><?php echo ($vo["id"]); ?></td>
            <?php if($vo["leve"] == '1'): ?><td><span class="groys"><button class="btn-green btn-xs" data-icon="plus"></button><?php echo ($vo["name"]); ?></span></td>
            <?php elseif($vo["leve"] == '2'): ?>
            <td style="padding-left: 8em;"><span class="groys"><button class="btn-green btn-xs" data-icon="minus"></button><?php echo ($vo["name"]); ?></span></td>
            <?php elseif($vo["leve"] == '3'): ?>
            <td style="padding-left: 15em"><?php echo ($vo["name"]); ?></td><?php endif; ?>
            <!-- <td><?php echo ($vo["mobile_name"]); ?></td> -->
            <td><?php if($vo["visibility"] == '1'): ?>是<?php else: ?>否<?php endif; ?></td>
            <?php if($vo["status"] == '0'): ?><td><a href="<?php echo U('Forms/update_class_status',array('id'=>$vo['id']));?>" data-type="get" data-toggle="doajax" data-confirm-msg="更改显示状态???">显示</a></td>
            <?php else: ?>
            <td><a href="<?php echo U('Forms/update_class_status',array('id'=>$vo['id']));?>" data-type="get" data-toggle="doajax" data-confirm-msg="更改关闭状态???">已关闭</a></td><?php endif; ?>
            <td><?php echo ($vo["sort"]); ?></td>
            <td>
                <button type="button" class="btn-blue" onclick="createDialog('<?php echo U("Forms/groy",array("id"=>$vo["id"]));?>', '编辑分类', 'groy', {width:600, height:450})">改</button>
                <a href="<?php echo U('Forms/del_goods_class',array('id'=>$vo['id']));?>" data-type="get" class="btn btn-red" data-toggle="doajax" data-confirm-msg="要删除这个分类?">删</a>
            </td>
        </tr><?php endforeach; endif; else: echo "" ;endif; ?>
        </tbody>
    </table>
</div>
<script>
$(function () {
    $('.groys').click(function () {
        var par = $(this).parents('tr');
        var flag = $(this).find('i.fa').hasClass('fa-plus');
        flag ? ($(this).find('i.fa').addClass('fa-minus').removeClass('fa-plus')) : ($(this).find('i.fa').addClass('fa-plus').removeClass('fa-minus'));
        var cls = par.hasClass('groy2');
        par.nextAll('tr').each(function() {
            if( $(this).hasClass('groy1') ) {
                return false;
            }else{
                if( !cls ){
                    $(this).hasClass('groy2') && ($(this).find('span.groys i.fa').addClass('fa-minus').removeClass('fa-plus'));
                    flag ? ($(this).show()) : ($(this).hide());
                }else{
                    $(this).toggle();
                }

            }
        });
    });
});
    
</script>

<div class="bjui-pageFooter">
		
	<?php if(page == save): ?><ul>
			<li><button type="submit" class="btn-default" data-icon="save">保存</button></li>
	        <li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
	    </ul>
	<?php elseif(page == close): ?>
	    <ul>
	        <li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
	    </ul>
	<?php elseif(page == page and $show != null): ?>
		<ul>
	        <li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
	    </ul>
		    <div class="pages">
		        <span>每页&nbsp;</span>
		        <div class="selectPagesize">
		            <select data-toggle="selectpicker" data-toggle-change="changepagesize">
		                <option value="<?php echo ($show['listrow']); ?>"><?php echo ($show['listrow']); ?></option>
		                <option value="60">60</option>
		                <option value="120">120</option>
		                <option value="150">150</option>
		            </select>
		        </div>
		        <span>&nbsp;条，共 <?php echo ($show['total']); ?> 条</span>
		    </div>
		    <div class="pagination-box" data-toggle="pagination" data-total="<?php echo ($show['total']); ?>" data-page-size="<?php echo ($show['listrow']); ?>" data-page-current="1">
		    </div>
	<?php elseif(page == page and $show == null): ?>
		<ul>
			<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
		</ul>
	<?php else: ?>
		<ul>
			<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
		</ul><?php endif; ?>

</div>